<?php
/**
 * 账单
 */
namespace App\Validation;

use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Validation\Validator\Numericality;

class RolesValidation extends BaseValidation
{
	public function initialize()
	{
		$this->add(
			"id",
			new Numericality(
				  [
					  "message" => ":field is not numeric",
					  "allowEmpty" => true,
				  ]
			)
		);

		$this->add(
			"role_name",
			new PresenceOf(
				  [
					  "message" => ":field is required",
					  // "allowEmpty" => true,
				  ]
			)
		);
        $this->add(
            "menu_nodes",
            new PresenceOf(
                [
                    "message" => ":field is required",
                    "allowEmpty" => true,
                ]
            )
        );
        $this->add(
            "city_id",
            new PresenceOf(
                [
                    "message" => ":field is required",
                    "allowEmpty" => true,
                ]
            )
        );
	}

	//验证之前
	public function beforeValidation($data, $entity, $messages)
    {  	  	
        return true;
    }
}